package models

import "time"

//创建帖子部份

type Post struct {
	PostID      int64     `json:"post_id" db:"post_id"`                              // 帖子id
	AuthorId    int64     `json:"-" db:"author_id"`                                  // 作者id
	CommunityID int64     `json:"community_id" db:"community_id" binding:"required"` // 社区Id
	Status      int32     `json:"status" db:"status" binding:"required"`             // 状态
	Title       string    `json:"title" db:"title" binding:"required"`               // 标题
	Content     string    `json:"content" db:"content" binding:"required"`           // 内容描述
	CreateTime  time.Time `json:"-" db:"create_time"`                                // 创建时间
}

type PostCommunity struct {
	PostID        int64     `json:"post_id" db:"post_id"`
	AuthorId      int64     `json:"-" db:"author_id"`
	CommunityID   int64     `json:"-" db:"community_id" binding:"required"`
	Status        int32     `json:"status" db:"status" binding:"required"`
	Title         string    `json:"title" db:"title" binding:"required"`
	Content       string    `json:"content" db:"content" binding:"required"`
	AuthorName    string    `json:"author_name"`
	CommunityName string    `json:"community_name"`
	CreateTime    time.Time `json:"-" db:"create_time"`
}

// 展示 帖子与社区类型的关系匹配
type CommunityPost struct {
	CommunityID   int64            `json:"community_id" db:"community_id"`
	CommunityName string           `json:"community_name" db:"community_name"`
	Child         []*PostCommunity `json:"child"`
}

//根据ID 获取帖子详情模块结构体
type ApiPostDetail struct {
	AuthorName string             `json:"author_name"`        // 作者名称
	VoteNum    int64              `json:"vote_num,omitempty"` // 投票数量
	*Post                         //嵌入帖子的结构体
	*Community `json:"community"` //嵌入社区的结构体
}

// 帖子的排序关系
type PostOrder struct {
	Id    int64  `db:"id"`
	Title string `db:"title"`
}
